package com.jdk.thread.lock.test2;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class ReentrantLockBeanchmark implements Counter {

	// 使用非公平锁，true就是公平锁
	private Lock lock = new ReentrantLock(false);

	private int count;

	@Override
	public long getValue() {
		return count;
	}

	@Override
	public void increment() {
		lock.lock();
		try {
			count++;
		} finally {
			lock.unlock();
		}
	}

}
